import type { ClassifyWallList } from "./classify";
import type { Config } from "@/utils/request";
import { request } from "@/utils/request";

export interface DownloadWall {
  id: string;
}
export interface UserInfo {
  IP: string;
  address: { country: string; province: string; city: string };
  downloadSize: number;
  scoreSize: number;
}

export const apiDownloadWall = (
  data: { classid: string; wallId: string },
  config?: Omit<Config, "data">
) => {
  return request<DownloadWall>("/downloadWall", {
    data,
    ...config,
    catch: () => {
      return {
        data: {
          id: "1234567",
        },
        errCode: 0,
        errMsg: "",
      };
    },
  });
};

export const apiUserInfo = () => {
  return request<UserInfo>("/userInfo", {
    catch: () => {
      return {
        data: {
          IP: "1234567",
          address: { country: "a", province: "b", city: "c" },
          downloadSize: 1,
          scoreSize: 1,
        },
        errCode: 0,
        errMsg: "",
      };
    },
  });
};

export const apiUserWallList = (
  data: {
    type?: "score" | "download";
    pageSize?: number;
    pageNum?: number;
  } = {}
) => {
  return request<ClassifyWallList[]>("/userWallList", {
    data,
    catch: () => {
      return {
        data: [
          {
            nickname: "全部",
            _id: "1234567",
            classid: "1234567",
            smallPicurl:
              "https://img2.baidu.com/it/u=3209353042,356122753&fm=253&fmt=auto&app=138&f=JPEG?w=889&h=500",
            description: `${Date.now()}`,
            tabs: ["好", "差"],
            score: "5",
          },
        ],
        errCode: 0,
        errMsg: "",
      };
    },
  });
};
